import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.iai.v20200303 import iai_client, models
cred = credential.Credential("AKIDQcZFj0xqZIupbAls6gbQQG0Yw4GspwZ9", "YsfJl293zkMm3f5M1Yu442oNsc9RVP6E")
httpProfile = HttpProfile()
httpProfile.endpoint = "iai.tencentcloudapi.com"

def face_orc(image_1,image_2):
    try:
        clientProfile = ClientProfile()
        clientProfile.httpProfile = httpProfile
        client = iai_client.IaiClient(cred, "ap-beijing", clientProfile)

        req = models.CompareFaceRequest()
        params = {
            "ImageA":image_1,
            "ImageB":image_2
        }
        req.from_json_string(json.dumps(params))
        resp = client.CompareFace(req)
        resp = json.loads(resp.to_json_string())
        return True,resp

    except TencentCloudSDKException as err:
        return False,err